//
//  LineEffect.hpp
//  client
//
//  Created by will on 17/07/2017.
//
//

#ifndef LineEffect_hpp
#define LineEffect_hpp

#include "cocos2d.h"

using namespace cocos2d;

enum class EffectStretchMode
{
    SCALING,
    TILED,
};

class LineEffect : public Sprite{
public:
    static LineEffect* create(const std::string& name="",EffectStretchMode mode=EffectStretchMode::SCALING);
public:
    LineEffect();
    ~LineEffect();

    void setStartPos(const Vec2&start);
    void setEndPos(const Vec2&end);
    
protected:
    bool init(const std::string& filename,EffectStretchMode mode);
    
    virtual void setSpriteFrame(SpriteFrame* newFrame) override;
    virtual void setTexture(Texture2D *texture) override;
    
    virtual void updateLinkPos();
protected:
    Vec2 _start;
    Vec2 _end;
    float _distance;
    Rect _originTexRect;
    EffectStretchMode _stretchMode;
};


#endif /* LineEffect_hpp */
